#include "NTuple.h"

//NTuple::NTuple(std::vector<Binding> &b);
NTuple::NTuple(const NTuple &t){
	bindings=t.bindings;
	variables=t.variables;
}
NTuple::NTuple(){}
NTuple::~NTuple(){}
void NTuple::addBinding(Binding b){
	bindings.push_back(b);
	variables.insert(b.variableName);
}
std::vector<Binding> NTuple::getBindings(){
	return this->bindings;
}
bool NTuple::hasBinding(int index){}
Binding NTuple::getBinding(int index){}
int NTuple::getSize(){
	return bindings.size();
}
bool NTuple::isEmpty(){
	return (bindings.empty());
}
Binding NTuple::getBinding(std::string variableName){}

std::set<std::string> NTuple::getAllVariables(){		// 获取binding中的所有变量,并把变量作为set返回。
	return variables;
}

bool NTuple::isContain(std::string variable){
	variable.erase(0,1);
	return variables.count(variable); //记住，此处的variable需要去掉头部的问号
}

std::string NTuple::toString(){
	std::string info;
	std::vector<Binding>::iterator beg=bindings.begin();
	std::vector<Binding>::iterator end=bindings.end();
	for(std::vector<Binding>::iterator it=beg;it!=end;it++){
		if(it!=beg){
			info+=" , ";
		}
		info += it->toString();
	}
	info += "\n";
	return info;
}
void NTuple::removeBinding(int i){}
void NTuple::project(std::vector<std::string> answerVars){}
void NTuple::addBinding(int index,Binding binding){}
bool NTuple::isCompatible(NTuple ntuple){}
